package com.econ.powercloud.ems.common.enums;

/**
 * 并离网类型枚举
 * @author jwc
 * @date 2022/08/09
 */
public enum GridTypeEnum implements EnumMethod{
    ON_GRID(1,"并网操作"),
    OFF_GRID(2,"离网操作");

    private Integer code;
    private String desc;


    GridTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public static String getDescFromCode(Integer code) {
        for (GridTypeEnum obj : GridTypeEnum.values()) {
            if (code.equals(obj.getCode())) {
                return obj.getDesc();
            }
        }
        return null;
    }

    public static GridTypeEnum fromCode(Integer code) {
        for (GridTypeEnum obj : GridTypeEnum.values()) {
            if (code.equals(obj.getCode())) {
                return obj;
            }
        }
        return ON_GRID;
    }
}
